<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <head>
    </head>
    <body>
        <ui:composition template="/templates/default.xhtml">
		
            <ui:define name="display">
            
                <div id="loading-div">
					<img src="#{request.contextPath}/resources/images/ajax-loader.gif" /> #{msg.working}
				</div>
            
            	<h:outputText value="#{msg.dbConfigName} > #{msg.dbName}" />
            
                <h1>#{msg.dbConfig}</h1>
                <h:messages id="successInfo" globalOnly="true" />
                <h:form prependId="false">
                
                	<h:outputText value="#{msg.dbMsg}" />
                                
                    <h:panelGrid columns="4">
                       
                        <h:outputText value="#{msg.dbType}:"/>
                 		<h:selectOneRadio id="type" value="#{databaseConfig.dbType}"
                                          onchange="submit()" immediate="true" valueChangeListener="#{databaseConfig.updateType}">
   							<f:selectItem itemValue="H2" itemLabel="H2" />
						   	<f:selectItem itemValue="MYSQL" itemLabel="MYSQL" />
						</h:selectOneRadio>
						<h:message for="type" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
						<h:outputText />
                    
                    	<h:outputText value="#{msg.username}:"/>
                        <h:inputText id="user" value="#{databaseConfig.dbUsername}" converter="#{defaultConverter}" />
                        <h:message for="user" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
                    	<h:outputText />
                    
                    	<h:outputText value="#{msg.password}:"/>
                        <h:inputSecret redisplay="true" id="password" value="#{databaseConfig.dbPassword}" converter="#{defaultConverter}" />
                        <h:message for="password" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
                        <h:outputText />
                        
                        <h:outputText value="#{msg.dbUrl}:"/>
                        <h:inputText id="url" value="#{databaseConfig.dbUrl}"
                                     binding="#{databaseConfig.inputText}" converter="#{defaultConverter}" size="50" disabled="true" />
                        <h:message for="url" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
                    	<h:commandButton action="#{databaseConfig.editUrl}" value="#{msg.lblEdit}" />
                    
                    	<h:outputText value="#{msg.dbDriver}:"/>
                        <h:inputText id="driver" value="#{databaseConfig.dbDriver}" converter="#{defaultConverter}" disabled="true" size="50" />
                        <h:message for="driver" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
                        <h:outputText />
                        
                        <h:outputText value="#{msg.dbShowSql}:"/>
                        <h:selectBooleanCheckbox id="showSql" value="#{databaseConfig.showSql}"/>
                        <h:outputText/>
                        <h:outputText/>
                        
                        <h:outputText value="#{msg.dbSaveTo}:"/>
                        <h:selectOneMenu id="saveTo" value="#{databaseConfig.dbSaveTo}">
                            <!-- Note: the label paths are informative only.
                             Canonical paths for reading are set in
                             application-context.xml and for writing are set in
                             DatabaseConfigBean.java -->
                            <f:selectItem itemValue="classpath" itemLabel="#{msg.dbSaveToCP}"/>
                            <f:selectItem itemValue="linuxUser" itemLabel="#{msg.dbSaveToLU}"/>
                            <f:selectItem itemValue="linuxEtc" itemLabel="#{msg.dbSaveToLS  }"/>
                            <f:selectItem itemValue="macUser" itemLabel="#{msg.dbSaveToMU}"/>
                            <f:selectItem itemValue="winUser" itemLabel="#{msg.dbSaveToWU}"/>
                        </h:selectOneMenu>
                        <h:message for="saveTo" errorClass="error" errorStyle="color: red" infoStyle="color: green"/>
                        <h:commandButton action="#{databaseConfig.saveChanges}" value="#{msg.lblSave}"/>
                        
                    </h:panelGrid>
                    
                    <h:outputText value="#{msg.dbSaveToNote}"/><br/><br/>
                    
                    <fieldset style="width:35%; display: #{databaseConfig.mysqlDisplay}">
                        <legend>#{msg.dbInitialData}</legend>
                        <h:outputText value="#{msg.dbInitializeDesc}"/>
                        <br/>
                        <h:commandButton action="#{databaseConfig.initializeDB}" value="#{msg.dbInitialize}"/>
                    </fieldset>
                    
                    <fieldset style="width:35%; display: #{databaseConfig.h2Display}">
                        <legend>#{msg.gettingStartedTestData}</legend>
                        <b>#{msg.gettingStartedSampleTestData}</b><br />
                        #{msg.gettingStartedSampleTestDataRequirements}<br /><br />

                        #{msg.gettingStartedEntityIds}:<br />
                        <table style="text-align:center">
                            <tr>
                                <td><b>#{msg.navBarIndividual}</b></td>
                                <td><b>#{msg.navBarLocation}</b></td>
                                <td><b>#{msg.navBarSocialGroup}</b></td>
                                <td><b>#{msg.navBarVisit}</b></td>
                            </tr>
                            <tr>
                                <td>MBI000001001</td>
                                <td>MBI000001</td>
                                <td>MBI00000100</td>
                                <td>VMBI0111</td>
                            </tr>
                            <tr>
                                <td>MBI000001002</td>
                                <td>MBI000002</td>
                                <td>MBI00000200</td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>MBI000001003</td>
                                <td>MBI000003</td>
                                <td>MBI00000300</td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>MBI000001004</td>
                                <td>MBI000004</td>
                                <td>MBI00000400</td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>MBI000001005</td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>MBI000001006</td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>MBI000001007</td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>MBI000001008</td>
                                <td></td>
                                <td></td>
                                <td></td>
                            </tr>
                        </table>
                        <br />
                        <h:commandButton styleClass="config" action="#{databaseConfig.executeTestScript}" value="#{msg.gettingStartedLoadTestData}" disabled="#{databaseConfig.testDataEnabled}" />
                    </fieldset>

                    <script>
						//<![CDATA[
						(function() {
							$('.config').click(function(evt) {
								$('#loading-div').css('visibility', 'visible');
							});
						})();
						//]]>
					</script>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
